import 'package:oi_ai_tool/util/oi_logger.dart';
import 'package:shared_preferences/shared_preferences.dart';

class OiStorage {
  static SharedPreferences? _stroageInstance;
  static _storageinstance() async {
    _stroageInstance ??= await SharedPreferences.getInstance();
  }

  static get(String key) async {
    await _storageinstance();
    var value = _stroageInstance!.get(key);
    OiLogger.info(msg: "get----------$value");
    return value;
  }

  static set(String key, dynamic value) async {
    await _storageinstance();
    return await _stroageInstance!.setString(key, value);
  }

  static Future<bool> remove(String key) async {
    await _storageinstance();
    return await _stroageInstance!.remove(key);
  }

  static exitKey(String key) async {
    await _storageinstance();
    return _stroageInstance!.containsKey(key);
  }
}

class StoreageKey {
  static const String _prefix = "oi_tool:";
  static const String TOKEN_KEY = "${_prefix}token_key";
  static const String ACCESS_KEY = "${_prefix}access_key";
  static const String CHAT_LIST = "${_prefix}chat_list";
  static const String ARCHIVE_LIST = "${_prefix}ARCHIVE_LIST";
}
